<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 4.2.1">
  <link rel="apple-touch-icon" sizes="180x180" href="/javascript/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/javascript/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/javascript/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/javascript/images/logo.svg" color="#222">

<link rel="stylesheet" href="/javascript/css/main.css">


<link rel="stylesheet" href="/javascript/lib/font-awesome/css/font-awesome.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"yoursite.com","root":"/javascript/","scheme":"Muse","version":"7.7.2","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}};
  </script>

  <meta name="description" content="let&#x2F;const 和var的区别 在本作用域中，let&#x2F;const 不会出现变量提升 在同一个作用域下，let&#x2F;const不能重复声明，在词法解析过程，如果出现重复声明，那么不会执行任何代码 let &#x2F; const 有暂时性死区，也就是说定义之前使用这个变量会报错。  函数变量提升的细节 在新版本的浏览器中，函数在条件判断中，不管，变量提升只声明，还没定义，只有条件成立的时候，才会进入定义 12">
<meta property="og:type" content="article">
<meta property="og:title" content="珠峰javascript">
<meta property="og:url" content="http://yoursite.com/2020/10/30/%E7%8F%A0%E5%B3%B0javascript/index.html">
<meta property="og:site_name" content="javascript">
<meta property="og:description" content="let&#x2F;const 和var的区别 在本作用域中，let&#x2F;const 不会出现变量提升 在同一个作用域下，let&#x2F;const不能重复声明，在词法解析过程，如果出现重复声明，那么不会执行任何代码 let &#x2F; const 有暂时性死区，也就是说定义之前使用这个变量会报错。  函数变量提升的细节 在新版本的浏览器中，函数在条件判断中，不管，变量提升只声明，还没定义，只有条件成立的时候，才会进入定义 12">
<meta property="og:locale" content="en_US">
<meta property="article:published_time" content="2020-10-30T00:27:45.244Z">
<meta property="article:modified_time" content="2020-11-03T14:17:29.324Z">
<meta property="article:author" content="HC">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="http://yoursite.com/2020/10/30/%E7%8F%A0%E5%B3%B0javascript/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'en'
  };
</script>

  <title>珠峰javascript | javascript</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="Toggle navigation bar">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <div>
      <a href="/javascript/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">javascript</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>


<nav class="site-nav">
  
  <ul id="menu" class="menu">
        <li class="menu-item menu-item-home">

    <a href="/javascript/" rel="section"><i class="fa fa-fw fa-home"></i>Home</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/javascript/archives/" rel="section"><i class="fa fa-fw fa-archive"></i>Archives</a>

  </li>
  </ul>

</nav>
</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content">
            

  <div class="posts-expand">
      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block " lang="en">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2020/10/30/%E7%8F%A0%E5%B3%B0javascript/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/javascript/images/avatar.gif">
      <meta itemprop="name" content="HC">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="javascript">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          珠峰javascript
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">Posted on</span>

              <time title="Created: 2020-10-30 08:27:45" itemprop="dateCreated datePublished" datetime="2020-10-30T08:27:45+08:00">2020-10-30</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">Edited on</span>
                <time title="Modified: 2020-11-03 22:17:29" itemprop="dateModified" datetime="2020-11-03T22:17:29+08:00">2020-11-03</time>
              </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h2 id="let-const-和var的区别"><a href="#let-const-和var的区别" class="headerlink" title="let/const 和var的区别"></a>let/const 和var的区别</h2><ol>
<li>在本作用域中，let/const 不会出现变量提升</li>
<li>在同一个作用域下，let/const不能重复声明，在词法解析过程，如果出现重复声明，那么不会执行任何代码</li>
<li>let / const 有暂时性死区，也就是说定义之前使用这个变量会报错。</li>
</ol>
<h2 id="函数变量提升的细节"><a href="#函数变量提升的细节" class="headerlink" title="函数变量提升的细节"></a>函数变量提升的细节</h2><ul>
<li><p>在新版本的浏览器中，函数在条件判断中，不管，变量提升只声明，还没定义，只有条件成立的时候，才会进入定义</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">fn(); <span class="comment">// 报错，fn is not a function</span></span><br><span class="line"><span class="keyword">if</span> (<span class="number">1</span> !== <span class="number">1</span>) &#123;</span><br><span class="line">	<span class="function"><span class="keyword">function</span> <span class="title">fn</span> (<span class="params"></span>) </span>&#123;</span><br><span class="line">		<span class="built_in">console</span>.log(<span class="number">1111</span>);</span><br><span class="line">	&#125;<span class="string">"</span></span><br><span class="line"><span class="string">&#125;</span></span><br></pre></td></tr></table></figure>

</li>
</ul>
<h2 id="简单理解this"><a href="#简单理解this" class="headerlink" title="简单理解this"></a>简单理解this</h2><ul>
<li>如果函数前面有<code>.</code>, 那么this指向的是<code>.</code>的前面， a.b.d.fn() ， 那么fn中的this就是a.b.d</li>
<li>如果前面没有<code>.</code>, 那么this指向window,  严格模式下是undefined</li>
</ul>
<h2 id="构造函数"><a href="#构造函数" class="headerlink" title="构造函数"></a>构造函数</h2><ul>
<li>每个函数都有一个原型</li>
<li>每个原型上都有一个属性constructor, 值是构造函数</li>
<li>每个对象都有一个<strong>proto</strong>, 指向所创建的函数的原型(除了Object.create(null))创建的除外</li>
</ul>
<h2 id="函数类型和对象类型"><a href="#函数类型和对象类型" class="headerlink" title="函数类型和对象类型"></a>函数类型和对象类型</h2><h2 id="函数类型"><a href="#函数类型" class="headerlink" title="函数类型"></a>函数类型</h2><ul>
<li>普通的函数</li>
<li>类</li>
</ul>
<h2 id="对象类型"><a href="#对象类型" class="headerlink" title="对象类型"></a>对象类型</h2><ul>
<li><p>{}</p>
</li>
<li><p>[]</p>
</li>
<li><p>正则对象</p>
</li>
<li><p>日期对象  Date()</p>
</li>
<li><p>Math对象</p>
</li>
<li><p>HTMLCollection元素的集合对象</p>
</li>
<li><p>实例(构造函数new 出来的)</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">funciton Person() &#123;&#125;</span><br><span class="line"><span class="keyword">const</span> person = <span class="keyword">new</span> Person();</span><br><span class="line"></span><br><span class="line"><span class="keyword">const</span> obj = <span class="keyword">new</span> <span class="built_in">Object</span>();</span><br><span class="line"><span class="keyword">const</span> arr = <span class="keyword">new</span> <span class="built_in">Array</span>();</span><br><span class="line"><span class="keyword">const</span> str = <span class="keyword">new</span> <span class="built_in">String</span>();</span><br><span class="line"><span class="keyword">const</span> data = <span class="keyword">new</span> <span class="built_in">Date</span>();</span><br><span class="line">...</span><br></pre></td></tr></table></figure>
</li>
<li><p>函数也是对象</p>
</li>
<li><p>函数的prototype也是对象 </p>
</li>
</ul>
<h2 id="Object和Function"><a href="#Object和Function" class="headerlink" title="Object和Function"></a>Object和Function</h2><ul>
<li><p><code>xx.__proto__</code>一般指的是创建出xx的原型，但是特别之处是<code>Function.__proto__ === Function.prototype</code></p>
</li>
<li><p>Number, String, Boolean, Object, Array, Date都是由Funtion创建出来的，因此，它们的<code>__proto__</code>都等于Function.prototype</p>
</li>
<li><p><code>Function.prototype.__proto__ === Object.prototype</code></p>
</li>
</ul>
<h2 id="new-和-的优先级"><a href="#new-和-的优先级" class="headerlink" title="new 和 .的优先级"></a>new 和 .的优先级</h2><p><a href="https://developer.mozilla.org/zh-CN/docs/web/javascript/reference/operators/operator_precedence" target="_blank" rel="noopener">mdn官网描述</a></p>
<ul>
<li><p>new和.的优先级是一样的</p>
</li>
<li><p>new 无参数列表优先级比new 有参列表优先级高</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">new</span> Foo.getName() <span class="comment">// .的优先级比new高</span></span><br><span class="line"><span class="keyword">new</span> Foo().getName() <span class="comment">// .的优先级和new的一样， 从左到右执行</span></span><br></pre></td></tr></table></figure>

</li>
</ul>
<h2 id="call不传参的情况"><a href="#call不传参的情况" class="headerlink" title="call不传参的情况"></a>call不传参的情况</h2><ul>
<li><p>非严格模式下，不传参指向的是window</p>
</li>
<li><p>严格模式下，不传参指向的是undefined</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">fn</span>(<span class="params"></span>) </span>&#123;&#125;</span><br><span class="line">fn.call(); <span class="comment">// 严格模式下，指向的是undefined  非严格模式下，指向的是window</span></span><br></pre></td></tr></table></figure>



</li>
</ul>

    </div>

    
    
    

      <footer class="post-footer">

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/javascript/2020/10/25/2020-10-25%E6%80%BB%E7%BB%93/" rel="prev" title="2020-10-25总结">
      <i class="fa fa-chevron-left"></i> 2020-10-25总结
    </a></div>
      <div class="post-nav-item">
    <a href="/javascript/2020/11/05/js%E6%9C%89%E5%85%B3%E7%9A%84%E7%9B%92%E5%AD%90%E6%A8%A1%E5%9E%8B/" rel="next" title="js有关的盒子模型">
      js有关的盒子模型 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  

  </div>


          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          Table of Contents
        </li>
        <li class="sidebar-nav-overview">
          Overview
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#let-const-和var的区别"><span class="nav-number">1.</span> <span class="nav-text">let&#x2F;const 和var的区别</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#函数变量提升的细节"><span class="nav-number">2.</span> <span class="nav-text">函数变量提升的细节</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#简单理解this"><span class="nav-number">3.</span> <span class="nav-text">简单理解this</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#构造函数"><span class="nav-number">4.</span> <span class="nav-text">构造函数</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#函数类型和对象类型"><span class="nav-number">5.</span> <span class="nav-text">函数类型和对象类型</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#函数类型"><span class="nav-number">6.</span> <span class="nav-text">函数类型</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#对象类型"><span class="nav-number">7.</span> <span class="nav-text">对象类型</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Object和Function"><span class="nav-number">8.</span> <span class="nav-text">Object和Function</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#new-和-的优先级"><span class="nav-number">9.</span> <span class="nav-text">new 和 .的优先级</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#call不传参的情况"><span class="nav-number">10.</span> <span class="nav-text">call不传参的情况</span></a></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">HC</p>
  <div class="site-description" itemprop="description"></div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/javascript/archives/">
        
          <span class="site-state-item-count">12</span>
          <span class="site-state-item-name">posts</span>
        </a>
      </div>
  </nav>
</div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2020</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">HC</span>
</div>
  <div class="powered-by">Powered by <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> v4.2.1
  </div>
  <span class="post-meta-divider">|</span>
  <div class="theme-info">Theme – <a href="https://muse.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Muse</a> v7.7.2
  </div>

        








      </div>
    </footer>
  </div>

  
  <script src="/javascript/lib/anime.min.js"></script>
  <script src="/javascript/lib/velocity/velocity.min.js"></script>
  <script src="/javascript/lib/velocity/velocity.ui.min.js"></script>

<script src="/javascript/js/utils.js"></script>

<script src="/javascript/js/motion.js"></script>


<script src="/javascript/js/schemes/muse.js"></script>


<script src="/javascript/js/next-boot.js"></script>




  















  

  

</body>
</html>
